package com.cbank.service;

import com.cbank.dao.ModuleShowDao;
import com.cbank.domain.ModuleShow;
import org.apache.ibatis.annotations.Param;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ModuleShowService {
    private Logger logger=Logger.getLogger(ModuleShowService.class);

    @Autowired
    private ModuleShowDao moduleShowDao;

    public ModuleShow getById(Integer id){
        return this.moduleShowDao.getById(id);
    }

    public ModuleShow getByViewId(String viewId){
        return this.moduleShowDao.getByViewId(viewId);
    }

    public List<ModuleShow> getListByModuleId(Integer moduleId){
        return this.moduleShowDao.getListByModuleId(moduleId);
    }

    public List<ModuleShow> getListByModuleIdAndType(Integer moduleId,Integer type){
        return this.moduleShowDao.getListByModuleIdAndType(moduleId,type);
    }

    public void save(ModuleShow moduleShow){
        ModuleShow moduleShowDb=this.moduleShowDao.getById(moduleShow.getId());
        if (moduleShowDb == null){
            this.moduleShowDao.insert(moduleShow);
        }else {
            this.moduleShowDao.update(moduleShow);
        }
    }

    public void updateStatus(Integer status,Integer moduleShowId){
        this.moduleShowDao.updateStatus(status,moduleShowId);
    }

    public List<String>  getAllDate(Integer moduleId){
        return this.moduleShowDao.getAllDate(moduleId);
    }

    public List<ModuleShow> getAllByDate(String publishTime,Integer moduleId){
        return this.moduleShowDao.getAllByDate(publishTime,moduleId);
    }
}
